package com.hex.ds.hdrs.period.job.dto;

import com.hex.ds.hdrs.common.enums.JobDefStatusEnum;
import com.hex.ds.hdrs.common.enums.JobPeriodEnum;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 周期作业定义下载模板类
 */
@Data
@Accessors(chain = true)
public class PeriodJobExportDto {

    private Integer index;

    private String jobCode;

    private String jobName;

    private String taskCode;

    private String taskName;

    private String shellPath;

    private String extParam;

    private String jobPeriod;

    private String dateExpression;

    private int offsetHour;

    private int priorityLevel;

    private String jobStatus;

    private String isWorkRun;

    private String appointAgentCode;

    private String isValidDate;

    private String jobStDate;

    private String jobEndDate;

    private String dependJob;

    private String dependTask;

    private int resNum;

    private String isOrder;

    private String isEndTask;

    private int allowErrCount;

    private String overPlanDuration;

    private int sortNo;

    private String isSingleJob;

    private String planExecDuration;

    private String labelName;

    private String operation = "更新";

    private String jobDesc;

    private String taskRemark;

    public String getIsSingleJob() {
        return ("1".equals(isSingleJob)) ? "是" : "否";
    }

    public String getDateExpression() {
        return ("1".equals(isSingleJob)) ? dateExpression : null;
    }

    public String getJobPeriod() {
        if (("1".equals(isSingleJob))){
            return JobPeriodEnum.D.getName();
        }else if (JobPeriodEnum.D.getName().equals(jobPeriod)) {
            return jobPeriod;
        } else {
            return jobPeriod + "[" + dateExpression + "]";
        }
    }

    public String getJobStatus() {
        return JobDefStatusEnum.fromJobPeriodEnum(jobStatus).getValue();
    }

    public String getIsWorkRun() {
        return ("1".equals(isWorkRun)) ? "是" : "否";
    }

    public String getIsValidDate() {
        return ("1".equals(isValidDate)) ? "是" : "否";
    }

    public String getIsOrder() {
        return ("1".equals(isOrder)) ? "是" : "否";
    }

    public String getIsEndTask() {
        return ("1".equals(isEndTask)) ? "是" : "否";
    }
}
